package com.example.fristactivity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class FirstActivity extends AppCompatActivity {

    private static final String TAG ="FirstActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_layout);
        Button button1=(Button) findViewById(R.id.button_1);
        Button button1_1=(Button) findViewById(R.id.button1_1);
        Button button1_2=(Button) findViewById(R.id.button2_2);

        button1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                finish();
            }
        });

        button1_1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                String data="Hello SecondActivity1";
                Intent intent=new Intent(FirstActivity.this,SecondActivity1.class);
                intent.putExtra("TextView",data);
                startActivity(intent);
            }
        });

        button1_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String data="Hello SecondActivity2";
                Intent intent=new Intent("com.example.fristactivity.ACTION_START");
                intent.addCategory("com.example.fristactivity.MY_CATEGORY");
                intent.putExtra("TextView",data);
                startActivity(intent);
            }
        });
    }
    protected void onDestroy(){
        super.onDestroy();
        Log.d(TAG,"FirstActivity”退出了，bye！“");
    }
}